import React from 'react'
import { connect } from 'react-redux'

export const HomePage = ({ count, list, add , init}) => {
    console.log(list)
    return (
        <div>
            HomePage -- { count }
            <button onClick={ add }>++</button>
            <button onClick={ init }>异步</button>
        </div>
    )
}

const mapStateToProps = (state) => {
    const { home } = state
    const { count, list } = home
    return {
        count,
        list
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
        add() {
            dispatch({ type: "home/ADD" })
        },
        init() {
            dispatch({ type: "home/init" })
        }
    }
}
export default connect(mapStateToProps, mapDispatchToProps)(HomePage)